function Toast(msg,duration){
    duration=isNaN(duration)?3000:duration;
    var m = document.createElement('div');
    m.innerHTML = msg;
    m.style.cssText="max-width:60%;min-width: 150px;padding:0 14px;height: 40px;color: rgb(255, 255, 255);line-height: 40px;text-align: center;border-radius: 4px;position: fixed;top: 50%;left: 50%;transform: translate(-50%, -50%);z-index: 999999;background: rgba(0, 0, 0,.7);font-size: 12px;";
    document.body.appendChild(m);
    setTimeout(function() {
      var d = 0.5;
      m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
      m.style.opacity = '0';
      setTimeout(function() { document.body.removeChild(m) }, d * 1000);
    }, duration);
}

//url参数
function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);//search,查询？后面的参数，并匹配正则
    if (r != null) return unescape(r[2]); return null;
}
// 转换时间戳
function formatTime(val) {
    const time = val < 1000000000000 ? new Date(val * 1000) : new Date(val);
    function timeAdd0(str) {
        if (str < 10) {
            str = `0${str}`;
        }
        return str;
    }
    // 年
    const y = time.getFullYear();
    // 月
    const m = time.getMonth() + 1;
    // 日
    const d = time.getDate();
    let result = `${y}.${timeAdd0(m)}.${timeAdd0(d)}`;
    return result;
}

function isPhone(num) {
    let reg = /^1[0-9]{10}$/;
    if (!reg.test(num)) {
        return false;
    }
    return true;
}
